package com.jghz.autoconfigure.dorado;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import com.bstek.dorado.web.servlet.DoradoServlet;
import com.bstek.dorado.web.servlet.SpringContextLoaderListener;
import com.jghz.configure.DoradoConfiguration;

@Configuration
@ConditionalOnClass(SpringContextLoaderListener.class)
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
@Import(DoradoConfiguration.class)
public class DoradoAutoConfiguration {

	@Bean
	public ServletRegistrationBean doradoServletRegistrationBean() {
		ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new DoradoServlet());
		servletRegistrationBean.addUrlMappings("*.d", "*.dpkg", "/dorado/*");
		servletRegistrationBean.setLoadOnStartup(1);
		return servletRegistrationBean;
	}

}
